import { request } from '@/utils/request';
import { RequestEnum } from '@/enums/httpEnum';

export const labelApi = {
  labelList: '/label/list',
  labelListJson: '/label/listJson',
  labelListByType: '/label/listByType',
  labelDetail: '/label/detail',
  labelAdd: '/label/add',
  labelUpdate: '/label/update',
  labelDelete: '/label/delete',
} as const;

export const getLabelListByType = (params: { type: number }) => {
  return request({
    url: labelApi.labelListByType,
    method: RequestEnum.GET,
    params,
  });
};
export const getLabelListJson = () => {
  return request({
    url: labelApi.labelListJson,
    method: RequestEnum.GET,
  });
};

export const createLabel = (data: API.CreateLabelParams) => {
  return request({
    url: labelApi.labelAdd,
    method: RequestEnum.POST,
    data,
  });
};

export const updateLabel = (data: API.UpdateLabelParams) => {
  return request({
    url: labelApi.labelUpdate,
    method: RequestEnum.PUT,
    data,
  });
};

export const deleteLabel = (params: { id: number }) => {
  return request({
    url: labelApi.labelDelete,
    method: RequestEnum.DELETE,
    params,
  });
};
